<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>体检记录</title>
</head>
<body>
<style type="text/css">
.recordBox .text-css,.printWin .text-css{
	border: 0px;
    text-align: center;
    width: 80px;
    height: 24px;
    outline: none;
    color:black;
}
</style>
<script type="text/javascript"> 
$(function(){
	$("#reportTable").datagrid({
		url:"ljw-examine-exok" ,
		onClickRow:function(index, row){ 
    		var eid = row.examine_id;
    		$.post(
    			"ljw-examine-exp",
    			{"eid":eid},
    			function(data){
    				$(".recordBox .nameEx").val(data[0].patient_name);
    				$(".recordBox .phoneEx").val(data[0].mzcard_phone);
    				$(".recordBox .addressEx").val(data[0].home_address);
    				$(".recordBox .costEx").val(data[0].cost.toFixed(2));
    			}
    		);
    		$("#exTable2").datagrid({
    			url:"ljw-examine-findByeid?eid="+eid,
    			columns:[[
    				{field:'examine_item_name',title:'项目',width:80,halign:'center'},
    				{field:'examine_record_result',title:'体检结果',width:120,halign:'center'},
    			]],
    			onClickRow:function(index){//设置不可选中
	    			$(this).datagrid('unselectRow',index);
	    		}
    		});
		}
	});
	
	//打印按钮                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
	$("#printBtn").click(function(){
		var row = $("#reportTable").datagrid("getSelected");
		if(row==null){
			return;
		}
		var eid = row.examine_id;
		$(".printWin").window("open");
		$.post(
   			"ljw-examine-exp",
   			{"eid":eid},
   			function(data){
   				$(".printWin .nameEx").val(data[0].patient_name);
   				$(".printWin .sexEx").val(data[0].patient_sex);
   				$(".printWin .ageEx").val(data[0].patient_age);
   				$(".printWin .numberEx").val(data[0].examine_id);
   				$(".printWin .costEx").val(data[0].cost.toFixed(2));
				$(".printWin .comboEx").val("无");
   				if(data[0].hasOwnProperty("combo_name")){
   	   				$(".printWin .comboEx").val(data[0].combo_name);
   	   				$(".printWin .priceEx").val(data[0].combo_price.toFixed(2));
   				}
   			}
    	);
		$("#printTable").datagrid({
			url:"ljw-examine-findByeid?eid="+eid,
			columns:[[
				{field:'examine_item_name',title:'项目',width:120,halign:'center'},
				{field:'examine_item_price',title:'单价',width:80,halign:'center',
					formatter:function(value,row,index){
    					return "￥" + value.toFixed(2);
					}
				},
				{field:'examine_record_result',title:'体检结果',width:120,halign:'center'},
				{field:'examine_record_time',title:'体检时间',width:180, align:'center',
					formatter:function(value,row,index){
						var time = new Date(value).toJSON();
						var date = new Date(+new Date(time)+8*3600*1000).toISOString().replace(/T/g,' ').replace(/\.[\d]{3}Z/,'') ;
						return date;
					}
				}
			]],
			onClickRow:function(index){//设置不可选中
				$(this).datagrid('unselectRow',index);
			}
		});
	});
	
	//打印完成按钮
	$("#printOkBtn").click(function(){
		$(".printWin").window("close");
	});
	
	//体检人搜索框
	$("#reportSear").searchbox({
		searcher:function(value){
			$('#reportTable').datagrid({url:"ljw-examine-exok?eid="+value});
		}
	});
});
</script>		
<div style="margin: 5px auto;width: 1100px" class="recordBox">
	<fieldset style="float :left;border-radius: 5px;border: 1px solid #ccc;width: 600px;margin: 5px auto;">
		<legend>体检人列表</legend>
		<div style="padding: 5px;">
			<input id="reportSear" class="easyui-searchbox" style="width:160px;height:28px;padding-left:5px;">
		</div>
		<table id="reportTable" style="height:360px;width:100%;" class="easyui-datagrid" data-options="fitColumns:true,singleSelect:true">
	 		<thead>  
		        <tr>
		            <th data-options="field:'examine_id',width:100,halign:'center'">体检号</th>   
		            <th data-options="field:'patient_name',width:120,halign:'center'">姓名</th>  
		            <th data-options="field:'patient_sex',width:80,halign:'center'">性别</th>
		            <th data-options="field:'card_cid',width:180,halign:'center'">身份证号</th>
		        </tr>   
	    	</thead>  
		</table>
	</fieldset>
	
	<fieldset style="height: 430px;display: inline-block; padding: 0px 10px;margin: 5px 10px;border: 1px solid #ccc;border-radius: 5px;">
		<legend>体检报告</legend>
		<p>
			<span style="display: inline-block;margin-left: 20px;">
				姓名：<input class="text-css nameEx" disabled="disabled" style="width: 94px;">
			</span>
			<span style="display: inline-block;margin-left: 30px;">
				联系电话：<input class="text-css phoneEx" style="width: 130px" disabled="disabled">
			</span>
		</p>
		<p>
			<span style="display: inline-block;margin-left: 20px;">
				家庭住址：<input class="text-css addressEx" style="width: 300px" disabled="disabled">
			</span>
		</p>
		<p>
			<span style="display: inline-block;margin-left: 20px;">
				总费用：<input class="text-css costEx" style="width: 110px" disabled="disabled">
			</span>
			<a id="printBtn" class="easyui-linkbutton" style="padding:0 5px;margin-left: 45px;">打印体检报告</a>
		</p>
		<table id="exTable2" style="height:264px;width:400px;" class="easyui-datagrid" data-options="fitColumns:true,singleSelect:true">
	 		<thead>  
		        <tr>
		        	<th data-options="field:'examine_item_name',width:80,halign:'center'">项目</th>   
		            <th data-options="field:'examine_record_result',width:120,halign:'center'" >体检结果</th>  
		        </tr>   
		    </thead>  
		</table> 
	</fieldset>
	
	<!-- 打印弹框  Start -->
	<div class="easyui-window printWin" title="体检报告" style="width:680px;user-select:none;"
		data-options="modal:true,collapsible:false,minimizable:false,
		maximizable:false,closed:true,draggable:false,shadow:true,resizable:false" style="padding:20px 40px">
		<div style="text-align: center;font-size: 22px;margin: 5px;">
			平 安 医 院
		</div>
		<div style="text-align: center;font-size: 16px;padding: 6px;border-bottom: 1px solid #CCC;">
			体检报告单
		</div>
		<p>
			<span style="display: inline-block;margin-left: 30px;">
				体检号：<input class="text-css numberEx" disabled="disabled" style="width: 90px;">
			</span>
			<span style="display: inline-block;margin-left: 30px;">
				姓名：<input class="text-css nameEx" disabled="disabled" style="width: 110px;">
			</span>
			<span style="display: inline-block;margin-left: 30px;">
				性别：<input class="text-css sexEx" style="width: 55px" disabled="disabled">
			</span>
			<span style="display: inline-block;margin-left: 30px;">
				年龄：<input class="text-css ageEx" style="width: 55px" disabled="disabled">
			</span>
		</p>
		<p>
			<span style="display: inline-block;margin-left: 30px;">
				体检套餐：<input class="text-css comboEx" disabled="disabled" style="width: 120px;">
			</span>
			<span style="display: inline-block;margin-left: 30px;">
				套餐价格：<input class="text-css priceEx" disabled="disabled" style="width: 80px;">
			</span>
			<span style="display: inline-block;margin-left: 30px;">
				总费用：<input class="text-css costEx" style="width: 80px" disabled="disabled">
			</span>
		</p>
		<table id="printTable" class="easyui-datagrid" style="height:280px" data-options="fitColumns:true">
		     
		</table> 
		<div style="background: #dee;padding: 10px;text-align: center;">
			<a id="printOkBtn" iconCls="icon-ok2" class="easyui-linkbutton" style="padding:0 5px;" id="opsBtn-ok">完成</a>
		</div>
	</div>
	<!-- 打印弹框  End-->
	
</div>
</body>
</html>